<template>

<el-dialog
    :close-on-click-modal="false"
    destroy-on-close
    :show-close="false"
    width="30%"
    v-model="ObsoleteSTATUS"
    title="候选人淘汰"
  >
  <!-- <el-form ref="ruleFormRef" :model="formData" :rules="formRules" size="small" :inline="false" label-width="100px">
    <el-form-item label="主题" prop="title">
      <el-input v-model="formData.title" placeholder="请输入主题" maxlength="32" size="small" />
    </el-form-item>
    <el-form-item label="候选人" prop="candidateId">
      <el-select v-model="formData.candidateId" placeholder="请选择候选人" filterable>
        <el-option v-for="item in candidateList" :key="item.id" :value="item.id" :label="item.name" />
      </el-select>
    </el-form-item>
    <el-form-item label="淘汰原因" prop="content">
      <editor v-model="formData.content" />
    </el-form-item>
    <el-form-item label="备注信息" prop="remark">
      <el-input v-model="formData.remark" placeholder="请填写备注信息" type="textarea" :rows="3" size="small"/>
    </el-form-item>
    <el-form-item label="优先度">
      <el-radio-group v-model="formData.priority">
        <el-radio :label="0" size="small">普通</el-radio>
        <el-radio :label="1" size="small">高</el-radio>
      </el-radio-group>
    </el-form-item>
  </el-form> -->
    <obsolete-form ref="form" :selecteTime="thisTime"></obsolete-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button size="large" @click="close()">取消</el-button>
        <el-button @click="submit()" type="primary" size="large">
          确认</el-button
        >
      </div>
    </template>
  </el-dialog>


</template>

<script>
// 淘汰
import {onMounted, reactive, toRefs,ref} from 'vue'
import ObsoleteForm from '/@/views/matter/components/ObsoleteForm.vue'
// import {getListByType} from '/@/api/oa/candidate'
// import { homeApi } from "/@/api/home/index";
// import { format } from "/@/views/home/component/lib/utils";
// import Editor from '/@/components/editor/AuthorityManage.vue'

// const homeCalendar = homeApi();
export default {
  name: 'Obsolete',
  components: {
    // Editor
    ObsoleteForm
  },
  props: {
    ObsoleteSTATUS: {
      type: Boolean,
      default: true,
    },
    idw: {
      type: String,
      default: "",
    },
    thisTime: {
      type: String,
      default: "",
    },
  },
  emits: ["ObsoleteCloseCloseClose"],
  setup(props, context) {
    const form = ref()
    const state = reactive({
      // formData: {
      //   candidateId: null,
      //   title: '候选人淘汰',
      //   content: null,   // 淘汰原因
      //   remark: null,   // 备注信息
      //   remindState: 'NONE',     // 提醒时间, 根据枚举类MatterRemindTimeEnum
      //   remindType: [],     // 提醒方式, 多选
      //   state: 0,           // 状态 -1草稿 0未开始 1进行中 2已完成 3已退回  4已取消 5已撤回
      //   priority: 0        // 优先级 0普通 1重要
      // },
      // candidateList: []
    })
    // const ruleFormRef = ref({});
    // const formRules = reactive({
    //   candidateId: {required: true, message: '请选择候选人', trigger: 'change'},
    //     title: {required: true, message: '请填写主题', trigger: 'blur'},
    //     content: {required: true, message: '请填写淘汰原因', trigger: 'blur'}
    // });
    // const getCandidateData = async () => {  // 获取所有
    //   try {
    //     const res = await getListByType('')
    //     state.candidateList = res.data
    //   } catch (e) {
    //     console.log(e)
    //   }
    // }
    // const resetForm = (formEl) => {
    //   if (!formEl) return;
    //   formEl.resetFields();
    // };
    let close = () => {
      context.emit("AnPaiormClose");
      form.value.reset()
      // resetForm(formEl);
    };
    let submit = async () => {
      form.value.submit()
      // state.formData.occurDate = format(state.occurDate, 'yyyy-MM-dd HH:mm')
      // state.formData.settlementDate = format(state.settlementDate, 'yyyy-MM-dd HH:mm')
      // state.form.id = idw.value;
      // if (!formEl) return;
      // await formEl.validate((valid, fields) => {
      //   if (valid) {
      //     state.formData.remindType = state.formData.remindType + '';
      //     // state.formData.executorIds = JSON.stringify(state.formData.executorIds)
      //     homeCalendar.addPlanInterview(state.formData).then((res) => {
      //       if (res.code === 0) {
      //         resetForm(formEl);
      //         close(formEl);
      //       }
      //     });
      //   } else {
      //     console.log("error submit!", fields);
      //   }
      // });

      // console.log(state.formData);
      // state.form.id = idw.value
      // homeCalendar
      //   .modifyMatter(state.formData)
      //   .then((res) => {
      //       if(res.code===1){

      //       }
      //   });
    };
    onMounted(() => {
      // getCandidateData()
    })
    return {
      ...toRefs(state),
      // getCandidateData,
      // ruleFormRef,
      submit,
      close,
      // resetForm,
      form
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
